package kr.bae.androidcomplete01.chapter06;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;

public class LayoutParameterEx extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		LinearLayout linear = new LinearLayout(this);
		linear.setOrientation(LinearLayout.VERTICAL);
		linear.setGravity(Gravity.CENTER);
		linear.setBackgroundColor(Color.LTGRAY);

		TextView tv = new TextView(this);
		tv.setText("TextView");
		tv.setTextColor(Color.RED);
		tv.setTextSize(20);
		tv.setBackgroundColor(Color.GREEN);
		
		TextView tv2 = new TextView(this);
		tv2.setText("TextView");
		tv2.setTextColor(Color.BLUE);
		tv2.setTextSize(20);
		tv2.setBackgroundColor(Color.MAGENTA);
		
		LinearLayout.LayoutParams params = new LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
		params.setMargins(0, 30, 0, 30); // textview margin
		linear.addView(tv, params);
		linear.addView(tv2, params);
		
		/*linear.addView(tv, LinearLayout.LayoutParams.WRAP_CONTENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);*/
		setContentView(linear);
	}
}
